package cn.tedu.sp13.controller;

import cn.tedu.sp11.entity.User;
import cn.tedu.sp11.service.UserService;
import cn.tedu.web.util.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class UserController {
    @Autowired
    private UserService userService;
    //根据用户ID获取用户
    @GetMapping("/{userId}")
    public JsonResult<User> getUser(@PathVariable Integer userId){
        User user = userService.getUser(userId);
        return JsonResult.ok().data(user);
    }
    // 根据用户ID 增加用户积分
    @GetMapping("/{userId}/score")
    public JsonResult<?> addScore(@PathVariable Integer userId,@RequestParam("score") Integer score){
        userService.addscore(userId,score);
        return JsonResult.ok().msg("增加积分成功!");
    }

    @GetMapping("/favicon.ico")
    public void ico(){

    }
}
